/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InterfaceModificaData.java
 *
 * Created on 06/07/2010, 15:05:27
 */

package gui;

import bean.Jogador;
import exception.ExceptionData;
import javax.swing.JOptionPane;

import controller.Sessao;

import util.Input;

/**
 * Interface utilizada para modificar Data de Nascimento do Jogador
 * @author Claudio Cardoso, Daniel Leite, Lucas Sampaio, Matheus Sampaio
 * @version 1.0
 */
public class InterfaceModificaData extends javax.swing.JFrame {
    /**
	 * 
	 */
	private static final long serialVersionUID = -1775730322885663219L;
	Jogador jogadorLogado = Sessao.getInstance().getJogadorLogado();

    /** Creates new form InterfaceModificaData */
    public InterfaceModificaData() {
        initComponents();
        setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        modificaAno = new javax.swing.JComboBox();
        separador2 = new javax.swing.JLabel();
        modificaData = new javax.swing.JButton();
        separador1 = new javax.swing.JLabel();
        modificaMes = new javax.swing.JComboBox();
        modificaDia = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Bolão da Copa P2 - Modifica Data");

        modificaAno.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1950", "1951", "1952", "1953", "1954", "1955", "1956", "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", "1965", "1966", "1967", "1968", "1969", "1970",
            "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991",
            "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010" }));

separador2.setText("/");

modificaData.setText("Ok");
modificaData.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
        modificaDataActionPerformed(evt);
    }
    });

    separador1.setText("/");

    modificaMes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));

    modificaDia.setModel(new javax.swing.DefaultComboBoxModel(new String[] {  "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(26, 26, 26)
            .addComponent(modificaDia, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(separador1)
            .addGap(18, 18, 18)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(12, 12, 12)
                    .addComponent(modificaData))
                .addGroup(layout.createSequentialGroup()
                    .addComponent(modificaMes, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(separador2)
                    .addGap(18, 18, 18)
                    .addComponent(modificaAno, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addContainerGap(24, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(32, 32, 32)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(modificaDia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(separador1)
                .addComponent(modificaMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(separador2)
                .addComponent(modificaAno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
            .addComponent(modificaData)
            .addContainerGap())
    );

    pack();
    }// </editor-fold>//GEN-END:initComponents

    private void modificaDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificaDataActionPerformed
        String data;

        int dia = Integer.parseInt(modificaDia.getModel().getSelectedItem().toString());
        int mes = Integer.parseInt(modificaMes.getModel().getSelectedItem().toString());
        int ano = Integer.parseInt(modificaAno.getModel().getSelectedItem().toString());

        try {
            data = Input.dataNascimentoGrafico(dia, mes, ano);

            jogadorLogado.setData(data);
            
            dispose();
        }catch (ExceptionData e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
            return;
        }
}//GEN-LAST:event_modificaDataActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new InterfaceModificaData().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox modificaAno;
    private javax.swing.JButton modificaData;
    private javax.swing.JComboBox modificaDia;
    private javax.swing.JComboBox modificaMes;
    private javax.swing.JLabel separador1;
    private javax.swing.JLabel separador2;
    // End of variables declaration//GEN-END:variables

}
